package com.af.system.monitor;

/**
 * @author : zhenyun.su
 * @comment : 时间记录
 * @since : 2020/1/21
 */

public class AfTimeRecord {
    private long startTime;
    private String methodName;
    public AfTimeRecord(String methodName){
        this.methodName = methodName;
        this.startTime = System.currentTimeMillis();
    }
    public static AfTimeRecord of(String methodName){
        return new AfTimeRecord(methodName);
    }

    public long calcTime(){
        long elapse = System.currentTimeMillis() - this.startTime;
        return elapse;
    }

    public String calcTimeString(){
        return String.format("%s consumed: %d millisecond", methodName, calcTime());
    }

}
